const user = {
  namespaced: true, // 一定要开始命名空间。
  state: {
    token: '' || localStorage.getItem('token'),
    userInfo: { username: '用户' } || localStorage.getItem('userInfo')
  },
  actions: {
  },
  mutations: {
    SET_TOKEN (state, val) {
      state.token = val
      localStorage.setItem('token', val)
    },
    SET_USERINFO (state, val) {
      state.userInfo = val
      localStorage.setItem('userInfo', val)
    }
  },
  getters: {
    getUserInfo (state) {
      return state.userInfo
    }
  }
}
export default user
